package com.ch3cooh.serviceuser.user.entity;

import lombok.Data;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.beans.BeanUtils;

import java.util.Date;

@Data
public class User {

    private Long id;

    private Long uuid;

    @Email(message = "邮箱格式不正确")
    private String email;

    @NotBlank(message = "密码不能为空")
    private String password;

    private String nickname;

    private String mobile;

    private Date createTime;

    private Date updateTime;

    /**
     * 将User 转换成 UserElement
     * @param user
     * @return
     */
    public static UserElement toUe(User user){
        UserElement ue = new UserElement();
        ue = new UserElement();
        ue.setEmail(user.getEmail());
        ue.setUserId(user.getId());
        ue.setUuid(user.getUuid());
        ue.setNickname(user.getNickname());
        return ue;
    }
}